package com.koron.housing.apply.bean.po;

import com.koron.bean.annocation.FillField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * 积分信息(HousingStaffIntegral)表实体类
 *
 * @author jzp
 * @since 2022-02-26
 */
@Data
@ApiModel(value = "积分信息", description = "HousingStaffIntegral")
public class HousingStaffIntegral {

    /**
     * ID
     */
    @FillField
    @ApiModelProperty("ID")
    private String id;

    /**
     * 申请单id
     */
    @ApiModelProperty("申请单id")
    private String applyId;

    /**
     * 学历积分
     */
    @ApiModelProperty("学历积分")
    private Integer edu;

    /**
     * 职称积分
     */
    @ApiModelProperty("职称积分")
    private Integer rank;

    /**
     * 工龄积分
     */
    @ApiModelProperty("工龄积分")
    private Integer age;

    /**
     * 荣誉积分
     */
    @ApiModelProperty("荣誉积分")
    private Integer honor;

    /**
     * 总积分
     */
    @ApiModelProperty("总积分")
    private Integer total;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @FillField
    private Date createTime;

    public Integer getTotal() {
        return total == null ? computeTotal() : total;
    }

    public Integer computeTotal() {
        return noNull(edu) + noNull(rank) + noNull(age) + noNull(honor);
    }

    private int noNull(Integer num) {
        return num == null ? 0 : num;
    }
}

